using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MFramework
{
    public class DataTableRow
    {
        public int Count { get; set; }

        private Dictionary<string, int> intDic = new Dictionary<string, int>();
        private Dictionary<string, float> floatDic = new Dictionary<string, float>();
        private Dictionary<string, string> stringDic = new Dictionary<string, string>();

        internal DataTableRow() { }

        public int GetInt(string key)
        {
            if (intDic.ContainsKey(key))
            {
                return intDic[key];
            }
            Logcat.Print("int value does not exsit for key:" + key, LogLevel.Error);
            return 0;
        }

        public float GetFloat(string key)
        {
            if (floatDic.ContainsKey(key))
            {
                return floatDic[key];
            }
            Logcat.Print("float value does not exsit for key:" + key, LogLevel.Error);
            return 0;
        }

        public string GetString(string key)
        {
            if (stringDic.ContainsKey(key))
            {
                return stringDic[key];
            }
            Logcat.Print("string value does not exsit for key:" + key, LogLevel.Error);
            return "";
        }

        internal void SetInt(string key, int value)
        {
            if (!intDic.ContainsKey(key))
            {
                Count++;
            }
            intDic[key] = value;
        }

        internal void SetFloat(string key, float value)
        {
            if (!floatDic.ContainsKey(key))
            {
                Count++;
            }
            floatDic[key] = value;
        }

        internal void SetString(string key, string value)
        {
            if (stringDic.ContainsKey(key))
            {
                Count++;
            }
            stringDic[key] = value;
        }
    }
}